package webdev.fragment;

import webdev.adapters.BookingAdapter;
import webdev.danagtravel.PlaceDetailActivity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import dev.danang.R;

public class ListBookingFragment extends Fragment {

	private ListView listBooking;
	private BookingAdapter mAdapter;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View layout = inflater.inflate(R.layout.fragment_list_booking, null);
		
		listBooking = (ListView) layout.findViewById(R.id.list_booking);
		mAdapter = new BookingAdapter(getActivity());
		listBooking.setAdapter(mAdapter);
		
		listBooking.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> adapter, View view, int position,
					long id) {
				Intent goToDetailPlace = new Intent(getActivity(), PlaceDetailActivity.class);
				Bundle bundle = new Bundle();
				bundle.putParcelable("places", mAdapter.getItemDiaDiem(position));
				goToDetailPlace.putExtras(bundle);
				getActivity().startActivity(goToDetailPlace);
			}
		});
		
		
		return layout;
	}

}
